package com.koron.order.application.service.impl;


import com.koron.order.application.bean.po.ApplicationDesc;
import com.koron.order.application.mapper.ApplicationDescMapper;
import com.koron.order.application.service.ApplicationDescService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 检修申请-追加备注信息(ApplicationDesc)表服务实现类
 *
 * @author jzp
 * @since 2021-10-11 10:18:24
 */
@Service
public class ApplicationDescServiceImpl implements ApplicationDescService {

    /**
     * 通过ID查询单条数据
     */
    @Override
    @TaskAnnotation("getById")
    public ApplicationDesc getById(SessionFactory factory, String id) {
        ApplicationDescMapper mapper = factory.getMapper(ApplicationDescMapper.class);
        return mapper.selectById(id);
    }

    /**
     * 查询所有数据
     */
    @Override
    @TaskAnnotation("list")
    public List<ApplicationDesc> list(SessionFactory factory, ApplicationDesc applicationDesc) {
        ApplicationDescMapper mapper = factory.getMapper(ApplicationDescMapper.class);
        return mapper.selectList(applicationDesc);
    }

    /**
     * 新增数据
     */
    @Override
    @TaskAnnotation("save")
    public boolean save(SessionFactory factory, ApplicationDesc applicationDesc) {
        ApplicationDescMapper mapper = factory.getMapper(ApplicationDescMapper.class);
        return mapper.insertOrUpdate(applicationDesc) > 0;
    }

    /**
     * 修改数据
     */
    @Override
    @TaskAnnotation("update")
    public boolean update(SessionFactory factory, ApplicationDesc applicationDesc) {
        ApplicationDescMapper mapper = factory.getMapper(ApplicationDescMapper.class);
        return mapper.update(applicationDesc) > 0;
    }

    /**
     * 通过主键删除数据
     */
    @Override
    @TaskAnnotation("deleteById")
    public boolean deleteById(SessionFactory factory, String id) {
        ApplicationDescMapper mapper = factory.getMapper(ApplicationDescMapper.class);
        return mapper.deleteById(id) > 0;
    }
}
